package com.example.kotlin_api.openclazz

import android.app.Activity

open class Food(val name: String) {
    constructor() : this("Food")

    fun description() = "Food:$name"
    open fun load() = "Food..."
    fun main(f: Food) {
        println(load())
        println(f is Apple)
        println(f is Activity)
        println(f is Any)
        // is 同 as （as 是智能转换）类型转换
        if (f is Apple) {
            val apple: Apple = f
            println(apple.special())
        }
    }
}

class Apple : Food("Apple") {
    override fun load() = "Apple loading"
    fun special() = "Apple Special"
    fun ext(): String {
        return let { "Apple Ext" }
    }
}
